package org.uim.cricket.updater.fetch.impl;

import org.uim.cricket.updater.fetch.Fetchable;
import org.uim.cricket.util.io.FileOpener;

public class FromFileFetcher implements Fetchable {

	private String file = null;
	
	public FromFileFetcher() {}
	
	public FromFileFetcher(String theFile) {
		this.file = theFile;
	}
	
	@Override
	public StringBuffer fetch(String input) throws Exception {
		//if (this.file == null && input == null) throw new IllegalArgumentException("File can't be empty!");
		
		this.file = input;
		FileOpener fo = new FileOpener(this.file);
		StringBuilder buffer = fo.open();
		
		return new StringBuffer(buffer.toString());
	}

	public void setFile(String file) {
		this.file = file;
	}
	
	public String getFile() {
		return file;
	}
}
